import { defineStore } from 'pinia'
export const useUserStore = defineStore({
    id: 'user',
    state: () => {
        return {
            token: '',
            userInfo: {
                
            }
        }
    },
    actions: {
        setToken(token) {
            this.token = token;
        },
        // 清除token 在退出登录时调用
        clearToken() { 
            this.token = '';
            // 清除用户信息
            this.userInfo = {};
        }
    },
    // 开启数据缓存
    persist: {
        enabled: true,
        strategies: [{
            key: 'xiaoluxian_user',
            storage: localStorage,
            //paths: ['token']
        }]
    }
})